#!/bin/sh

CURRENTDIR=`pwd`
BASEDIR=$(cd "$(dirname "$0")"; pwd)
NGINXDIR=$BASEDIR/bin
PIDFILE=$BASEDIR/log/nginx.pid

start_nginx()
{
	$NGINXDIR/nginx
}

stop_nginx()
{
	$NGINXDIR/nginx -s stop
}

reload_nginx()
{
	$NGINXDIR/nginx -s reload
}

restart_nginx()
{
	stop_nginx
	start_nginx
}

test_nginx()
{
	$NGINXDIR/nginx -t
}

cd $BASEDIR

case $1 in
        'start')

                # Start nginx
                start_nginx
                ;;

        'stop')

                # Stop nginx
                stop_nginx
                ;;

        'reload')
		
                # Reload nginx
                reload_nginx	
		;;

        'restart')
		
                # Start nginx
                restart_nginx
		;;
		
        'test')
		
                # Test nginx
                test_nginx
		;;
esac

cd $CURRENTDIR

exit 0
